package com.fr.lintcode;

import org.junit.Test;

/**
*作者：furong
*日期：2017年3月2日
*时间：下午4:56:10
*/
public class Q392 {
    /**
     * @param A: An array of non-negative integers.
     * return: The maximum amount of money you can rob tonight
     */
    public long houseRobber(int[] A) {
        if (A == null || A.length <= 0) {
            return 0;
        }
        int length = A.length;
        long dp[][] = new long[length + 1][2];
        for (int i = 1; i <= length; i++) {
            dp[i][0] = Math.max(dp[i - 1][0], dp[i - 1][1]);
            dp[i][1] = dp[i - 1][0] + A[i - 1];
        }
        return Math.max(dp[length][0], dp[length][1]);
    }

    @Test
    public void testA() {
        int[] A = { 3, 8, 7, 3 };
        System.out.println(houseRobber(A));
    }
}
